#include <bits/stdc++.h>
using namespace std;
struct qj{
    long long l ,r;
}k[100005];
long long t, n, m, ll, lv, v[100005],d[100005],a[100005],p[100005],ri[1000005],le[1000005],ri2[1000005],cnt,cnt2,rmax;
long long read(){
    long long x=0, f=1;
    char c=getchar();
    while(c>'9'||c<'0')if(c=='-')f=-1,c=getchar();else f=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return f*x;
}
bool cmp(qj aa, qj bb){
    return aa.r<bb.r;
}
int main(){
    freopen("detect.in","r", stdin);
    freopen("detect.out","w", stdout);
    t=read();
    while(t--){
        cnt=0,rmax=0,cnt2=0;
        for(long long i = ll+1; i >= 0; i--)ri2[i]=1000000000,ri[i]=0,le[i]=0;
        n=read(),m=read(),ll=read(),lv=read();
        for(long long i =  0; i < n; i++){
            d[i] = read(),v[i] = read(),a[i] = read();
        }
        for(long long i =  0; i < m; i++)p[i]=read();
        sort(p,p+m);
        for(long long i =  0; i < m; i++)ri2[p[i]]=0,ri[p[i]]=i,le[p[i]]=i;
        for(long long i = ll+1; i >= 0; i--){
            ri2[i]=min(ri2[i],ri2[i+1]+1);
            if(!ri[i])ri[i]=ri[i+1];
        }
        for(long long i = 1; i <= ll+1; i++)if(!le[i])le[i]=le[i-1];
        for(long long i =  0; i < n; i++){
            if(a[i]>0&&v[i]*v[i]+2*a[i]*(p[m-1]-d[i])>lv*lv)
                rmax=max(rmax,ri[d[i]+(long long)((long double)(-v[i]*v[i]+lv*lv+2*a[i]-1)/(long double)(2*a[i]))]),cnt2++;
            else if(a[i]<0&&v[i]*v[i]+2*a[i]*ri2[d[i]]>lv*lv&&d[i]+(long long)((long double)(-lv*lv+v[i]*v[i]-0.01)/(long double)(-2*a[i]))>=ll)
                rmax=max(rmax,ri[d[i]]),cnt2++;
            else if(a[i]==0&&v[i]>lv)
                rmax=max(rmax,ri[d[i]]),cnt2++;
            else if(a[i]<0&&v[i]*v[i]+2*a[i]*ri2[d[i]]>lv*lv)
                k[cnt].l=ri[d[i]],k[cnt].r=le[d[i]+(long long)((long double)(-lv*lv+v[i]*v[i]-0.01)/(long double)(-2*a[i]))],cnt++;
        }
        long long ans=0,po=0;
        if(cnt){
            ans++;
            po=k[0].r;
            sort(k, k+cnt,cmp);
            for(long long i = 1; i < cnt; i++){
                if(k[i].l<=po)continue;
                ans++;
                po=k[i].r;
            }
        }
        if(cnt2||cnt)
            if(po<rmax)ans++;
        cout<<cnt+cnt2<<" ";
        cout<<m-ans<<"\n";
    }
    return 0;
}
